package q.test0421library.Mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import q.test0421library.Moudle.BookInfo;
import q.test0421library.Moudle.PageRequest;

import java.util.List;

@Mapper
public interface BookMapper {
   @Insert("insert into book_info (book_name,author,count,price,publish) values " +
           "(#{bookName},#{author},#{count},#{price},#{publish})")
    public abstract Integer addBook(BookInfo book);

   @Select("SELECT COUNT(1) FROM book_info WHERE status <> 0")
    int count();


    @Select("select * from book_info where status !=0 order by id desc limit #{offset}, #{pageSize}")
    List<BookInfo> getListByPage(PageRequest request);

    @Select("select * from book_info where id=#{bookId} and status <> 0")
    BookInfo queryBookById(Integer bookid);



}
